package bday.tvlport.models;

import java.text.SimpleDateFormat;
import java.util.Date;

import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.mapping.Document;

@Document(collection = "users")
public class UserDetails {

	@Id
	private String id;
	private String userId;
	private String name;
	private String email;
	private int dobMonthDate;
	
	public UserDetails(String id, String userId, String name, String email, int dobMonthDate) {
		this.id = id;
		this.userId = userId;
		this.name = name;
		this.email = email;
		this.dobMonthDate = dobMonthDate;
	}
	
	public String getId() {
		return id;
	}
	public void setId(String id) {
		this.id = id;
	}
	public String getUserId() {
		return userId;
	}
	public void setUserId(String userId) {
		this.userId = userId;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String getEmail() {
		return email;
	}
	public void setEmail(String email) {
		this.email = email;
	}
	public int getDobMonthDate() {
		return dobMonthDate;
	}
	public void setDobMonthDate(int dobMonthDate) {
		this.dobMonthDate = dobMonthDate;
	}
	@SuppressWarnings("deprecation")
	public String getDobMonthString() {
		Date date = new Date(1970, dobMonthDate / 100 - 1, 1);
		SimpleDateFormat sdf = new SimpleDateFormat("MMM");
		return sdf.format(date);
	}

	public String getDobDateString() {
		return dobMonthDate % 100 + "";
	}

	public String getCombinedDate() {
		return getDobMonthString() + ", " + getDobDateString();
	}

	@Override
	public String toString() {
		//SimpleDateFormat sdf = new SimpleDateFormat("dd-MMM-yyyy");
		//Date dob = new Date(dobYear, dobMonthDate / 100, dobMonthDate % 100);
		return "User [userid=" + userId + ", name=" + name + ", email=" + email
				+ ", dobMonth=" + dobMonthDate/100 + ", dobDate=" + dobMonthDate%100 + "]";
	}
}
